//
//  HNSH_RefundDetailShopView.m
//  HNSH_SingleProject
//
//  Created by 李宇廷 on 2023/3/6.
//

#import "HNSH_RefundDetailShopView.h"

@interface HNSH_RefundDetailShopView ()
/**  */
@property (nonatomic, strong)UILabel * titleLabel;
/**  */
@property (nonatomic, strong)UIImageView * shopImgView;
/**  */
@property (nonatomic, strong)UILabel * shopNameLabel;
/**  */
@property (nonatomic, strong)UILabel * shopDesLabel;
/**  */
@property (nonatomic, strong)UILabel * shopPriceLabel;
@end

@implementation HNSH_RefundDetailShopView

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor whiteColor];
        [self configUI];
    }
    return self;
}

- (void)configUI {
    [self addAllViews];
    [self addAllLayout];
}

//MARK: Cycle Methods
- (void)addAllViews{
    self.backgroundColor = [UIColor whiteColor];
    [self addSubview:self.titleLabel];
    [self addSubview:self.shopImgView];
    [self addSubview:self.shopNameLabel];
    [self addSubview:self.shopDesLabel];
    [self addSubview:self.shopPriceLabel];
}

- (void)addAllLayout{
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(16);
        make.top.mas_equalTo(16);
        make.height.mas_equalTo(22);
    }];
    [self.shopImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(16);
        make.width.height.mas_equalTo(90);
        make.top.mas_equalTo(self.titleLabel.mas_bottom).offset(16);
    }];
    [self.shopNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.shopImgView.mas_right).offset(12);
        make.right.mas_equalTo(-16);
        make.height.mas_equalTo(22);
        make.top.mas_equalTo(self.shopImgView.mas_top);
    }];
    [self.shopDesLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(self.shopNameLabel);
        make.height.mas_equalTo(18);
        make.top.mas_equalTo(self.shopNameLabel.mas_bottom).offset(4);
    }];
    [self.shopPriceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.shopNameLabel);
        make.right.mas_equalTo(-100);
        make.height.mas_equalTo(22);
        make.bottom.mas_equalTo(self.shopImgView.mas_bottom);
    }];
}

//MARK: Setter Methods
- (void)setModel:(HNSH_RefundDetailModel *)model{
    _model = model;
    
    if (model.items.count) {
        HNSH_ConfirmOrderGoodsModel * subModel = model.items.firstObject;
        [self.shopImgView sd_setImageWithURL:[NSURL URLWithString:subModel.left_icon] placeholderImage:[UIImage imageNamed:@"icon_place_zfx"]];
        self.shopNameLabel.text = subModel.title;
        self.shopDesLabel.text = subModel.sku_text;
        self.shopPriceLabel.attributedText = [NSString transAttWithSting:subModel.price_text];
    }
}

//MARK: Getter Methods
- (UILabel *)titleLabel{
    if (!_titleLabel) {
        _titleLabel = [UILabel new];
        _titleLabel.font = [UIFont boldSystemFontOfSize:16];
        _titleLabel.textColor = [UIColor appBlack333LabelColor];
        _titleLabel.text = @"退款信息";
    }
    return _titleLabel;
}

- (UIImageView *)shopImgView{
    if (!_shopImgView) {
        _shopImgView = [UIImageView new];
        _shopImgView.layer.cornerRadius = 8;
        _shopImgView.layer.masksToBounds = YES;
    }
    return _shopImgView;
}

- (UILabel *)shopNameLabel{
    if (!_shopNameLabel) {
        _shopNameLabel = [UILabel new];
        _shopNameLabel.font = [UIFont boldSystemFontOfSize:16];
        _shopNameLabel.textColor = [UIColor appBlack333LabelColor];
    }
    return _shopNameLabel;
}

- (UILabel *)shopDesLabel{
    if (!_shopDesLabel) {
        _shopDesLabel = [UILabel new];
        _shopDesLabel.font = [UIFont systemFontOfSize:13];
        _shopDesLabel.textColor = [UIColor colorWithHexString:@"#999999"];
    }
    return _shopDesLabel;
}

- (UILabel *)shopPriceLabel{
    if (!_shopPriceLabel) {
        _shopPriceLabel = [UILabel new];
        _shopPriceLabel.font = [UIFont boldSystemFontOfSize:16];
        _shopPriceLabel.textColor = [UIColor appBlack333LabelColor];
    }
    return _shopPriceLabel;
}

@end
